
package jp.moisture.othello.player.search;

import jp.moisture.othello.board.Board;
import jp.moisture.othello.board.Board.State;
import jp.moisture.othello.board.Cell;
import jp.moisture.othello.board.Stone;

public class CandidateCell implements Comparable<CandidateCell> {
    public int mColor;
    public Board mBoard;
    public Cell mCell;
    public State mState;

    public CandidateCell(int color, Board board, Cell cell) {
        mColor = color;
        mCell = cell;
        mBoard = new Board(board);
        mBoard.setStone(cell.getX(), cell.getY(), mColor);
        mState = mBoard.getState();
    }

    @Override
    public int compareTo(CandidateCell o) {
        return o.mState.getPoint(mColor) - mState.getPoint(mColor);
    }

    public final boolean isWideMarginWon(int color) {
        return mState.isWideMarginWon(color);
    }

    @Override
    public String toString() {
        return Stone.toString(mColor) + "(" + mCell.getX() + ","
                + mCell.getY() + "):" + mState.getPoint(mColor);
    }

    public boolean isWon() {
        return mState.isWon(mColor);
    }

}
